from __future__ import annotations

from dataclasses import dataclass


@dataclass
class SafetyDistanceCheck:
    required_m: float
    available_m: float
    ok: bool
    note: str


def dynamic_safety_distance(swing_m: float, clearance_m: float, allowance_m: float = 0.5) -> SafetyDistanceCheck:
    req = swing_m + allowance_m
    ok = clearance_m >= req
    return SafetyDistanceCheck(required_m=req, available_m=clearance_m, ok=ok, note="动态距离：摆幅+附加量")


def static_safety_distance(min_spec_m: float, available_m: float) -> SafetyDistanceCheck:
    return SafetyDistanceCheck(required_m=min_spec_m, available_m=available_m, ok=available_m >= min_spec_m, note="通用最小净距")


